package org.gpf.game.tank.offline;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;

/**
 * 血块，吃了涨血
 * @author gaopengfei
 * @date 2015-5-8 下午12:47:33
 */
public class Blood {

	int x,y,w,h;
	TankClient tc;
	int step = 0;
	private boolean live = true;
	public boolean isLive() {
		return live;
	}
	public void setLive(boolean live) {
		this.live = live;
	}

	// 血块运动的轨迹，由position中的各个点构成
	private int[][] position= {{360,420},{280,540},{70,280},{260,420},{400,200},{520,520},{134,134}};
	
	public Blood() {
		x = position[0][0];
		y = position[0][1];
		w = h = 15;
	}
	
	public void draw(Graphics g){
		
		if(!live) return;
		
		Color c = g.getColor();
		g.setColor(Color.BLUE);
		g.fillRect(x, y, w, h);
		g.setColor(c);
		
		move();
	}

	private void move() {

		step++;
		if (step == position.length) {
			step = 0;
		}
		x = position[step][0];
		y = position[step][1];
	}
	
	public Rectangle getRect(){
		
		return new Rectangle(x, y, w, h);
	}
}
